﻿
(function () {
    appModule.controller('common.views.disputeInformationHandles.duBanList', [
        '$scope', '$uibModalInstance', 'abp.services.app.disputeInformation', 'disputeInformationId', 'abp.services.app.notification', 'appUserNotificationHelper',
        function ($scope, $uibModalInstance, disputeInformationService, disputeInformationId, notificationService, appUserNotificationHelper) {
            var vm = this;
            vm.saving = false;
            //首先将disputeInformation数据设置为null
            vm.disputeInformation = null;

            //vm.filterText = $stateParams.filterText || '';

            //请求参数，默认用于分页
            vm.requestParams = {
                sorting: null,
                userID: 0,
                entityId: disputeInformationId
            };

            //取消关闭页面
            vm.cancel = function () {
                $uibModalInstance.dismiss();
            };

            //初始化页面
            function init() {

                disputeInformationService.getDisputeInformationForEditAsync({
                    id: disputeInformationId
                }).then(function (result) {
                    vm.disputeInformation = result.data.disputeInformation;
                    vm.requestParams.userID = vm.disputeInformation.userID;

                    notificationService.getUserNotificationsByUserIdAsync($.extend({ filter: "" }, vm.requestParams)).then(function (result) {

                        vm.data = _.map(result.data.items, function (item) {
                            var data = appUserNotificationHelper.formatExtend(item, false);
                            //if (data.state == "UNREAD") {
                            //    data.state = false;
                            //}
                            //else {
                            //    data.state = true;
                            //}
                            return data;
                        });

                        if (vm.data.length == 0) {
                            vm.IsTableShow = false;
                            vm.IsRecordShow = true;
                        }
                        else {
                            vm.IsTableShow = true;
                            vm.IsRecordShow = false;
                        }

                    });
                });
            }

            //执行初始化方法
            init();
        }
    ]);
})();